﻿@using Bonobo.Git.Server.Extensions;
@model UserDetailModelList
@{
    ViewBag.Title = Resources.Account_Index_Title;
}

<div class="pure-g">
    <div class="pure-u-3-5">
        <h1>@Resources.Account_Index_Title</h1>
    </div>
    <div class="pure-u-2-5 add">
        @if (!User.IsWindowsAuthenticated() && !Model.IsReadOnly)
        {
            <a class="pure-button pure-button-primary" href="@Url.Action("Create")"><i class="fa fa-plus-circle"></i> @Resources.Account_Index_Create</a>
        }
    </div>
</div>


@if (TempData["CreateSuccess"] != null && (bool)TempData["CreateSuccess"])
{
    <div class="summary-success">
        <p id="@TempData["NewUserId"]">@Resources.Account_Create_Success</p>
    </div>
}
@if (TempData["DeleteSuccess"] != null)
{
    if ((bool)TempData["DeleteSuccess"])
    {
        <div class="summary-success">
            <p>@Resources.Account_Delete_Success</p>
        </div>
    }
    else
    {
        <div class="summary-error">    
            <p>@Resources.Account_Delete_DeleteCurrentUser</p>
        </div>
    }
}


@{
    var grid = new WebGrid(source: Model, defaultSort: "Username", rowsPerPage: 15);
    @grid.GetHtml(
        tableStyle: "pure-table users",
        columns: grid.Columns(
        grid.Column("Username", header: typeof(UserDetailModel).GetDisplayValue("Username"), format: (item) => Html.ActionLink((string)item.Username, "Detail", new { id = item.Id }, new { @class = "detail" })),
        grid.Column("Name", typeof(UserDetailModel).GetDisplayValue("Name")),
            grid.Column("Surname", typeof(UserDetailModel).GetDisplayValue("Surname")),
            grid.Column("Email", typeof(UserDetailModel).GetDisplayValue("Email")),
            grid.Column(format: (item) => item.IsReadOnly ? Html.Raw(String.Empty) : Html.ActionLink(" ", "Edit", new { id = item.Id }, new { @class = "edit", title = Resources.Grid_Edit }), style: "action"),
            grid.Column(format: (item) => item.IsReadOnly ? Html.Raw(String.Empty) : Html.ActionLink(" ", "Delete", new { id = item.Id }, new { @class = "delete", title = Resources.Grid_Delete }), style: "action")
        )
    )
}